home *** CD-ROM | disk | FTP | other *** search
/ Ultra Gameplayers 101 / Ultra Game Players Magazine, No. 101 - September 1997 (Imagine Publishing, Inc.)(1997).iso / pc / new_ugp.dxr / 00264_Text Display Class.ls < prev    next >
Encoding:
Text File  |  1997-07-10  |  2.9 KB  |  101 lines

  1. property spritenum, memberNum, ancestor, windowBottom, basePos
  2.  
  3. on new me, parameterList
  4.   set spritenum to getProp(parameterList, #spritenum)
  5.   set memberNum to getaProp(parameterList, #memberNum)
  6.   if stringp(memberNum) then
  7.     set memberNum to the number of member memberNum
  8.   end if
  9.   set windowBottom to getaProp(parameterList, #windowBottom)
  10.   set basePos to getaProp(parameterList, #basePos)
  11.   if not objectp(basePos) then
  12.     set basePos to the loc of sprite spritenum
  13.   end if
  14.   set textString to getaProp(parameterList, #initText)
  15.   if stringp(textString) and (memberNum > 0) then
  16.     set the text of member memberNum to textString
  17.   end if
  18.   return me
  19. end
  20.  
  21. on init me, newText
  22.   if memberNum <= 0 then
  23.     set memberNum to the memberNum of sprite spritenum
  24.   end if
  25.   set the text of member memberNum to newText
  26.   if the puppet of sprite spritenum = 1 then
  27.     set the loc of sprite spritenum to basePos
  28.     set the memberNum of sprite spritenum to memberNum
  29.   else
  30.     set basePos to the loc of sprite spritenum
  31.   end if
  32.   set the visible of sprite spritenum to 1
  33. end
  34.  
  35. on ScrollPercent me, percent
  36.   if the puppet of sprite spritenum = 0 then
  37.     set basePos to the loc of sprite spritenum
  38.     if memberNum <= 0 then
  39.       set memberNum to the memberNum of sprite spritenum
  40.     end if
  41.     puppetSprite(spritenum, 1)
  42.   end if
  43.   set windowHeight to windowBottom - the locV of basePos
  44.   set range to the height of member memberNum - windowHeight
  45.   if range < 0 then
  46.     set range to 0
  47.   end if
  48.   set diff to range * percent / 100
  49.   set the locV of sprite spritenum to the locV of basePos - diff
  50.   updateStage()
  51. end
  52.  
  53. on ScrollLines me, delta
  54.   if the puppet of sprite spritenum = 0 then
  55.     set basePos to the loc of sprite spritenum
  56.     if memberNum <= 0 then
  57.       set memberNum to the memberNum of sprite spritenum
  58.     end if
  59.     puppetSprite(spritenum, 1)
  60.   end if
  61.   set lineShift to lineHeight(member memberNum, 1)
  62.   set pixelShift to lineShift * delta
  63.   set windowHeight to windowBottom - the locV of basePos
  64.   set range to the height of member memberNum - windowHeight
  65.   if range < 0 then
  66.     set range to 0
  67.   end if
  68.   set minYPos to the locV of basePos - range
  69.   set yPos to the locV of sprite spritenum
  70.   set yPos to yPos + pixelShift
  71.   if yPos > the locV of basePos then
  72.     set yPos to the locV of basePos
  73.   else
  74.     if yPos < minYPos then
  75.       set yPos to minYPos
  76.     end if
  77.   end if
  78.   puppetSprite(spritenum, 1)
  79.   set the locV of sprite spritenum to yPos
  80.   updateStage()
  81. end
  82.  
  83. on clear me
  84.   if memberNum <= 0 then
  85.     set memberNum to the memberNum of sprite spritenum
  86.   end if
  87.   set the text of member memberNum to " "
  88.   set the visible of sprite spritenum to 0
  89. end
  90.  
  91. on dispose me
  92.   put "dispose Text Display Class" && me
  93.   puppetSprite(spritenum, 0)
  94.   set the visible of sprite spritenum to 1
  95.   set basePos to 0
  96.   if objectp(ancestor) then
  97.     dispose(ancestor)
  98.   end if
  99.   set ancestor to 0
  100. end
  101.